package com.example.demo.equipment.controller;

import com.example.demo.equipment.dao.CollectingSpace;
import com.example.demo.equipment.service.CollectingSpaceService;
import com.example.demo.system.utility.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 采集空间配置
 */
@RequestMapping("space")
@RestController
public class CollectingSpaceController {

    @Autowired
    private CollectingSpaceService collectingSpaceService;

    @RequestMapping("getList")
    public Result getList(@RequestParam(value = "pageNum")Integer pageNum,
                          @RequestParam(value = "pageSize")Integer pageSize,
                          @RequestParam(value = "name", required = false)String name){
        return collectingSpaceService.getList(pageNum,pageSize,name);
    }

    @RequestMapping("get")
    public Result get(Integer id){
        return Result.success(collectingSpaceService.get(id));
    }

    @RequestMapping("add")
    public Result add(@RequestBody CollectingSpace collectingSpace){
        return collectingSpaceService.add(collectingSpace);
    }

    @RequestMapping("update")
    public Result update(@RequestBody CollectingSpace collectingSpace){
        return collectingSpaceService.update(collectingSpace);
    }

    @RequestMapping("delete")
    public Result delete(Integer id){
        return collectingSpaceService.delete(id);
    }
}
